/*    */ package com.zimbra.cs.account.ldap;
/*    */ 
/*    */ import com.zimbra.common.account.ZAttrProvisioning.AutoProvMode;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.ldap.ZAttributes;
/*    */ import com.zimbra.soap.type.AutoProvPrincipalBy;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AutoProvisionManual
/*    */   extends AutoProvision
/*    */ {
/*    */   private AutoProvPrincipalBy by;
/*    */   private String principal;
/*    */   private String password;
/*    */   
/*    */   protected AutoProvisionManual(LdapProv prov, Domain domain, AutoProvPrincipalBy by, String principal, String password)
/*    */   {
/* 38 */     super(prov, domain);
/* 39 */     this.by = by;
/* 40 */     this.principal = principal;
/* 41 */     this.password = password;
/*    */   }
/*    */   
/*    */   Account handle() throws ServiceException
/*    */   {
/* 46 */     if (!autoProvisionEnabled()) {
/* 47 */       throw ServiceException.FAILURE("MANUAL auto provision is not enabled on domain " + this.domain.getName(), null);
/*    */     }
/*    */     
/*    */ 
/* 51 */     return createAccount();
/*    */   }
/*    */   
/*    */   private boolean autoProvisionEnabled() {
/* 55 */     Set<String> modesEnabled = this.domain.getMultiAttrSet("zimbraAutoProvMode");
/* 56 */     return modesEnabled.contains(ZAttrProvisioning.AutoProvMode.MANUAL.name());
/*    */   }
/*    */   
/*    */   private Account createAccount() throws ServiceException
/*    */   {
/*    */     String acctZimbraName;
/* 62 */     if (this.by == AutoProvPrincipalBy.dn) {
/* 63 */       ZAttributes externalAttrs = getExternalAttrsByDn(this.principal);
/* 64 */       AutoProvision.ExternalEntry externalEntry = new AutoProvision.ExternalEntry(this.principal, externalAttrs);
/* 65 */       acctZimbraName = mapName(externalAttrs, null); } else { String acctZimbraName;
/* 66 */       if (this.by == AutoProvPrincipalBy.name) {
/* 67 */         AutoProvision.ExternalEntry externalEntry = getExternalAttrsByName(this.principal);
/* 68 */         acctZimbraName = mapName(externalEntry.getAttrs(), this.principal);
/*    */       } else {
/* 70 */         throw ServiceException.FAILURE("unknown AutoProvPrincipalBy", null); } }
/*    */     AutoProvision.ExternalEntry externalEntry;
/*    */     String acctZimbraName;
/* 73 */     ZimbraLog.autoprov.info("auto creating account in MANUAL mode: " + acctZimbraName);
/* 74 */     return createAccount(acctZimbraName, externalEntry, this.password, ZAttrProvisioning.AutoProvMode.MANUAL);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/AutoProvisionManual.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */